package cn.zh.npro.Adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import java.util.ArrayList;

import cn.zh.npro.Item.SgItem;
import cn.zh.npro.R;

/**
 * Created by WYN on 2018/4/24 0024.
 */

public class GsAdapter extends BaseAdapter{
    Context context;
    ArrayList<SgItem> arrayList;
    LayoutInflater inflater;

    public GsAdapter(Context context,ArrayList<SgItem> arrayList){
        this.context=context;
        this.arrayList=arrayList;
        inflater=LayoutInflater.from(context);
      }

    @Override
    public int getCount() {
        return arrayList.size();
    }

    @Override
    public Object getItem(int i) {
        return arrayList.get(i);
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        Holder holder=null;
        if (null==view){
            holder=new Holder();
            view=inflater.inflate(R.layout.gs_layout,null,false);
            holder.stname=view.findViewById(R.id.stname);
            holder.txtnum=view.findViewById(R.id.txtnum);
            view.setTag(holder);
          }else {
            holder= (Holder) view.getTag();
          }
           holder.stname.setText(arrayList.get(i).getWarehouseName());
           holder.txtnum.setText(arrayList.get(i).getStock()+"");
         return view;
         }




    class Holder{
        TextView stname,txtnum;
    }

}
